package com.demo.pattern.single;

// 懒汉式，线程不安全
public class DemoTest3 {
    public static void main(String[] args) {
        System.out.println(Single3.getInstance() == Single3.getInstance());
    }
}

class Single3 {

    // 私有构造方法，外部不能new
    private Single3() {
    }

    public static Single3 instance;

    public static Single3 getInstance() {
        if (instance == null) {
            instance = new Single3();
        }
        return instance;
    }
}